package com.turing.post.transaction.util;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.turing.post.util.PCPSUtil;

@SuppressWarnings("serial")
@Entity
@Table(name = "MCHCHKACCCTL")
@IdClass(MchChkAccCtl.class)
public class MchChkAccCtl implements Serializable {

	/**
	 * 商户ID
	 */
	private String merchantNo;

	@Id
	@Column(name = "MERCHANTNO", nullable = false)
	public String getMerchantNo() {
		return merchantNo;
	}

	public void setMerchantNo(String merchantNo) {
		this.merchantNo = merchantNo;
	}

	/**
	 * 对帐日期
	 */
	private Date checkDate;

	@Id
	@Column(name = "CHECKDATE", nullable = false)
	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	/**
	 * 对帐结果
	 */
	private String checkResult;

	/**
	 * 0-完全成功
	 */
	public static final String CHECKRESULT_SUCC = "0";

	/**
	 * 1-尚未核对
	 */
	public static final String CHECKRESULT_NOCHECK = "1";

	/**
	 * 2-调整一致
	 */
	public static final String CHECKRESULT_ADJUST = "2";

	/**
	 * 3-需人工干预
	 */
	public static final String CHECKRESULT_MANUAL = "3";

	/**
	 * 9-未收到对账请求
	 */
	public static final String CHECKRESULT_NOACC = "9";

	@Column(name = "CHECKRESULT", nullable = false)
	public String getCheckResult() {
		return checkResult;
	}

	public void setCheckResult(String checkResult) {
		this.checkResult = checkResult;
	}

	/**
	 * 对帐文件ID
	 */
	private BigInteger checkFileId;

	@Column(name = "CHECKFILEID", nullable = true)
	public BigInteger getCheckFileId() {
		return checkFileId;
	}

	public void setCheckFileId(BigInteger checkFileId) {
		this.checkFileId = checkFileId;
	}

	/**
	 * 借方笔数
	 */
	private BigInteger debitCount;

	@Column(name = "DEBITCOUNT", nullable = false)
	public BigInteger getDebitCount() {
		return debitCount;
	}

	public void setDebitCount(BigInteger debitCount) {
		this.debitCount = debitCount;
	}

	/**
	 * 借方金额
	 */
	private BigInteger debitAmt;

	@Column(name = "DEBITAMT", nullable = false)
	public BigInteger getDebitAmt() {
		return debitAmt;
	}

	public void setDebitAmt(BigInteger debitAmt) {
		this.debitAmt = debitAmt;
	}

	/**
	 * 贷方笔数
	 */
	private BigInteger creditCount;

	@Column(name = "CREDITCOUNT", nullable = false)
	public BigInteger getCreditCount() {
		return creditCount;
	}

	public void setCreditCount(BigInteger creditCount) {
		this.creditCount = creditCount;
	}

	/**
	 * 贷方金额
	 */
	private BigInteger creditAmt;

	@Column(name = "CREDITAMT", nullable = false)
	public BigInteger getCreditAmt() {
		return creditAmt;
	}

	public void setCreditAmt(BigInteger creditAmt) {
		this.creditAmt = creditAmt;
	}

	@Override
	public int hashCode() {
		return PCPSUtil.getObjectListHashCode(new Object[] { getMerchantNo(),
				getCheckDate() });
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof MchChkAccCtl))
			return false;
		MchChkAccCtl other = (MchChkAccCtl) obj;
		if (!PCPSUtil
				.compareObject(this.getMerchantNo(), other.getMerchantNo()))
			return false;

		return PCPSUtil
				.compareObject(this.getCheckDate(), other.getCheckDate());
	}
}